package com.sig.slider;

import com.sig.MainActivity;
import com.sig.R;

import android.annotation.SuppressLint;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.ViewGroup;

@SuppressLint("NewApi") public class Slider extends ActionBarDrawerToggle{

	private MainActivity activity;
	static int icon_slider = R.drawable.ic_drawer;
	static int slider_ouvert = R.string.drawer_open; /* "open drawer" description for accessibility */
	static int slider_ferme = R.string.drawer_close; /* "close drawer" description for accessibility */

	private ViewGroup slider_views;

	private SliderClickListener click_listener;

	public Slider(MainActivity activity, DrawerLayout page){		
		super(activity,page,icon_slider,slider_ouvert,slider_ferme);
		this.activity = activity;
		this.slider_views = (ViewGroup) activity.findViewById(R.id.slider_views);

		ajouter_listener();
	}
	
	public void ajouter_listener(){
		this.click_listener = new SliderClickListener(activity);

		for(int i=0;i<this.slider_views.getChildCount();i++){
			View view = this.slider_views.getChildAt(i);
			if(view instanceof ViewGroup)
				view.setOnClickListener(click_listener);
		}
	}

	public void onDrawerClosed(View view) {
		activity.invalidateOptionsMenu(); 
		// call onPrepareOptionsMenu()
	}

	public void onDrawerOpened(View drawerView) {
		activity.invalidateOptionsMenu(); 
		// call onPrepareOptionsMenu()
	}

};